package cn.tedu.uep.function.service.impl;

import cn.tedu.uep.function.mapper.FunctionMapper;
import cn.tedu.uep.function.pojo.dto.FunctionQuery;
import cn.tedu.uep.function.pojo.dto.FunctionSaveParam;
import cn.tedu.uep.function.pojo.entity.Function;
import cn.tedu.uep.function.pojo.vo.FunctionVO;
import cn.tedu.uep.function.service.FunctionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author HUAWEI
* 针对表【application】的数据库操作Service实现
* @createDate 2024-12-18 15:06:31
*/
@Slf4j
@Service
public class FunctionServiceImpl implements FunctionService {

    @Autowired
    private FunctionMapper functionMapper;

    @Override
    public List<FunctionVO> selectFunction(FunctionQuery functionQuery) {
        log.debug("加载服务列表业务{}",functionQuery);
        List<FunctionVO> list = functionMapper.selectFunction(functionQuery);
        return list;
    }

    @Override
    public void saveFunction(FunctionSaveParam functionSaveParam) {
        Function function = new Function();
        BeanUtils.copyProperties(functionSaveParam,function);
        if (function.getFunctionId()==null) {
            log.debug("新增服务业务{}",functionSaveParam);
            function.setCreateTime(new Date());
            functionMapper.saveFunction(function);
        }else{
            log.debug("修改服务业务{}",functionSaveParam);
            function.setUpdateTime(new Date());
            functionMapper.updateFunction(function);
        }
    }

    @Override
    public void deleteFunction(Integer functionId) {
        log.debug("删除服务业务{}",functionId);
        functionMapper.deleteFunction(functionId);
    }
}




